<template>
  父组件{{ count }}{{ dataList }}
  <button @click="btnClick">改变父组件中的数组</button>
  <hr />
  <Son></Son>
</template>

<script>
import { computed } from 'vue'
import Son from './son.vue'
export default {
  name: 'HelloWorld',
  data() {
    return {
      count: 0,
    }
  },
  components: { Son },
  data() {
    return {
      dataList: [1, 2, 3],
      count: 0,
    }
  },
  methods: {
    btnClick() {
      this.dataList.push(4)
    },
  },
  // provide: {
  //   name: 'zjd',
  //   age: 18,
  //   click() {
  //     console.log(this.count)
  //     console.log(1111)
  //   },
  // },
  provide() {
    return {
      name: 'zjd',
      age: 18,
      dataLength: computed(() => this.dataList.length),
      click: () => {
        console.log(this.dataList)
        this.count += 1
      },
    }
  },
}
</script>
<style scoped></style>
